<?php

class Core_Model_Website_Block extends Dcmp_Model_Entity {

    public function __construct() {
        parent::__construct();
    }

    protected function getTableClass() {
        return Kd_Loader::loadClass('table_website_block');
    }

    protected function initializeTable($table) {
        $table->setName('{t}website_block');
        $table->createColumn('id', 'integer', TRUE, TRUE);
        $table->createColumn('code', 'string');
        $table->createColumn('name', 'string');
        $table->createColumn('module_id', 'integer');
        $table->createColumn('area_id', 'integer')->setUpdateable(FALSE);
        $table->createColumn('enabled', 'integer');
        $table->createColumn('parameters', 'serialize');
        $table->createColumn('creator_id', 'integer');
        $table->createColumn('created_time', 'datetime')->setDefaultValue(date('Y-m-d H:i:s'));
        $table->createColumn('template_script', 'string');
        $table->createColumn('share_template_name', 'string');
    }

    public function loadByCode($code){
        $row = $this->getTable()->getByCode($code);
        $this->fill($row);
        return $this;
    }
}
